<?php

namespace App\Services\User;

use App\Constants\CodeData;
use App\Dao\CommonSettingDao;
use App\Dao\UserDao;
use App\Exception\MessageException;
use App\Model\Anchor;
use App\Model\AnchorVideo;
use App\Model\Gift;
use App\Model\IncomeExpense;
use App\Model\Photo;
use App\Model\User;
use App\Model\UserCheckImgLog;
use App\Model\UserDel;
use App\Model\UserDelLimit;
use App\Model\UserIdentity;
use App\Utils\MemcacheClient;
use App\Utils\MongoDBClient;
use Hyperf\Context\Context;
use Hyperf\DbConnection\Db;
use Throwable;

class ResourceService
{
    /**
     * Note - vip用户查看用户私密图片/视频
     * DateTime 2024/7/18 16:29
     * User Admin
     * @param $userInfo
     * @param mixed $type
     * @return array
     */
    public function vipSeeVideoOrPhoto($userInfo, mixed $type)
    {
        if ($userInfo['super_noble'] != 1 && $userInfo['noble'] != 1) {
            throw new MessageException('vip用户才能查看', CodeData::NEED_TIPS);
        }

        $id = $userInfo['id'];

        if ($type == 1) {
            $data = AnchorVideo::select(["id", "title", "url", "is_recommend"])->where("id", $id)->get();
        } else {
            $data = Photo::select(["id", "name", "path", "status", "is_recommend"])->where("id", $id)->get();
        }
        $data = modelToArray($data);
        UserCheckImgLog::updateOrInsert(
            ["resource_id" => $id, "uid" => $id, "type" => $type],
            ["ctime" => time()]
        );

        return formatData($data);

    }


}